package aash.catalog.views.field;

import aash.catalog.views.panel.PropertyPanel;
import java.awt.Color;
import javax.swing.JFormattedTextField;

/**
 * Property Field for Explorer View.
 * @author Aashintan
 */
public class PropertyField extends JFormattedTextField {
    /**
     * Default serial UID.
     */
    private static final long serialVersionUID = 5532213497447450865L;
    /**
     * Key of the field.
     */
    private String key;
    /**
     * X position of the label.
     */
    private final int posX = 100;
    /**
     * Width of the label.
     */
    private final int width = 120;
    /**
     * Height of the label.
     */
    private final int height = 20;
    /**
     * Step between each line.
     */
    private final int step = 40;
    /**
     * First line to use.
     */
    private final int firstLine = 30;

    /**
     * Class constructor.
     * @param stKey of the field
     * @param pp the panel under the field
     * @param iLine of the field
     */
    public PropertyField(final String stKey, final PropertyPanel pp, final int iLine) {
        super();
        key = stKey;
        setOpaque(true);
        setBackground(Color.GRAY);
        setBounds(pp.getX() + posX, pp.getY() + (iLine * step) + firstLine, width, height);
    }

    /**
     * Class constructor.
     * @param stKey of the field
     * @param pp the panel under the field
     * @param iLine of the field
     * @param stValue of the field
     */
    public PropertyField(final String stKey, final PropertyPanel pp, final int iLine, final String stValue) {
        super();
        key = stKey;
        if (stValue != null) {
            setText(stValue);
        }
        setOpaque(true);
        setBackground(Color.GRAY);
        setBounds(pp.getX() + posX, pp.getY() + (iLine * step) + firstLine, width, height);
    }

    /**
     * @return the key
     */
    public final String getKey() {
        return key;
    }
}
